<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>试卷维护</title>
<%@include file="/view/common/js-css.jsp" %>
<style type="text/css"> 
  body{ 
    text-align:center; 
  } 
  .graph{ 
    width:100%; 
    height:25px; 
  }
  
  #bar{ 
        display:block; 
        background:#45c8dc; 
        float:left; 
        height:100%; 
        text-align:center; 
    } 
    #barNum{ 
        position:absolute; 
    } 
</style> 
<script type="text/javascript"> 

var bar=0;
function $(obj){ //封装方法，相当于jQuery
    return document.getElementById(obj); 
} 
function go1() {
	document.getElementById("cc").style.display = "block";
	bar = window.setInterval("go()",30); //设置定时器
}

function go(){ 
	if($("bar").style.width != "100%"){ 
	    $("bar").style.width = parseInt($("bar").style.width) + 1 + "%"; 
	    $("bar").innerHTML = $("bar").style.width; 
	    if($("bar").style.width == "100%"){ 
	      	window.clearInterval(bar); //进度为100时清除定时器
	      	document.getElementById("cc").style.display = "none";
	        alert('试卷生成成功！');
	        window.location.href=getContextPath()+"/PageServlet?command=paperBuild";
	    } 
	}
} 


function getContextPath() {
    var pathName = document.location.pathname;
    var index = pathName.substr(1).indexOf("/");
    var result = pathName.substr(0,index+1);
    return result;
}

</script>
</head>
<body>
	<div id="frameWrapper" class="frameWrapper">
		<div class="titlebar">
			<p>
				当前位置：试卷管理<span>/</span>试卷维护
			</p>
		</div>
		<div class="searchbar">
			<form method="post" action="">
				<div id="input">
					<div class="inputwraper">
						<span>试卷名称：</span> <input type="text" name="paperName"/>
					</div>
					<div class="inputwraper">
						<span>科目：</span> <input type="text" name="subjectName"/>
					</div>
					<div id="sub-btn">
						<input type="submit" value="搜素">
					</div>
					<div class="clear"></div>
				</div>
			</form>
		</div>
		<div id="table-wrap">
			<table border="1">
				<thead>
					<tr>
						<th>编号</th>
						<th>试卷名</th>
						<th>科目</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				<c:forEach items="${paging.list }" var="paper">
					<tr>
						<td>${paper.paper_id }</td>
						<td>${paper.paper_name }</td>
						<td>${paper.subject_name }</td>
						<td class="do"> <a onclick="go1();"
							class="btn btn-update"><i class="fa fa-pencil"></i>生成试卷</a></td>
					</tr>
				</c:forEach>
				</tbody>
			</table>
			<div class="graph" id="cc" > 
				<strong id="bar" style="width:0%;"></strong>
			</div>
			<div id="paging">
				<a class="btn btn-getionfo" href="${pageContext.request.contextPath }/PageServlet?command=paperBuild&currentPage=1" target="iframe">首页</a>
				<a class="btn btn-getionfo" href="${pageContext.request.contextPath }/PageServlet?command=paperBuild&currentPage=${paging.currentPage-1<1?1:paging.currentPage-1 }" target="iframe">上一页</a>
				&nbsp;&nbsp;&nbsp;&nbsp;
				共<span>${paging.pageTotal } </span>页
				&nbsp;&nbsp;&nbsp;&nbsp;
				当前第<span>${paging.currentPage }</span>页
				&nbsp;&nbsp;&nbsp;&nbsp;
				<a class="btn btn-getionfo" href="${pageContext.request.contextPath }/PageServlet?command=paperBuild&currentPage=${paging.currentPage+1>paging.pageTotal?paging.pageTotal:paging.currentPage+1 }" target="iframe">下一页</a>
				<a class="btn btn-getionfo" href="${pageContext.request.contextPath }/PageServlet?command=paperBuild&currentPage=${paging.pageTotal}" target="iframe">末页</a>
			</div>
		</div>
	</div>
</body>
</html>